<?php

namespace app\test717\controller;

use think\Controller;
use think\Request;

class Login extends Controller
{
  public function login()
  {
        //接收所有post提交参数
        $params = input('get.');
        $url = sprintf(config('wx.Url'),config('wx.AppId'),config('wx.AppSecret'),$params['code']);

        //获取openid
        $data = $this->geturl($url);

        dump($data);die();
        //转成数组



  }


  public function geturl($url)
  {

          $headerArray =array("Content-type:application/json;","Accept:application/json");
          $ch = curl_init();
          curl_setopt($ch, CURLOPT_URL, $url);
          curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
          curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
          curl_setopt($ch,CURLOPT_HTTPHEADER,$headerArray);
          $output = curl_exec($ch);
          curl_close($ch);
          $output = json_decode($output,true);
          return $output;
  }
}
